1use super::RealTimeData;
2use num_enum::{IntoPrimitive, TryFromPrimitive};
3
4#[derive(Debug, Clone)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct GameData {
7 pub game_build: u32,
9
10 pub game_state: Result<GameState, u32>,
12
13 pub language: Result<GameLanguage, u32>,
15}
16
17impl GameData {
18 pub unsafe fn read(data: *const RealTimeData) -> Self {
23 Self {
24 game_build: (*data).game_build,
25 game_state: (*data).game_state.try_into(),
26 language: (*data).language.try_into(),
27 }
28 }
29}
30
31#[derive(
32 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TryFromPrimitive, IntoPrimitive,
33)]
34#[num_enum(error_type(name = u32, constructor = From::from))]
35#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
36#[cfg_attr(
37 feature = "strum",
38 derive(
39 strum::AsRefStr,
40 strum::Display,
41 strum::EnumCount,
42 strum::EnumIter,
43 strum::IntoStaticStr,
44 strum::VariantArray,
45 strum::VariantNames
46 )
47)]
48#[repr(u32)]
49pub enum GameState {
50 CharacterSelection,
51 CharacterCreation,
52 Cinematic,
53 LoadingScreen,
54 Gameplay,
55}
56
57#[derive(
58 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TryFromPrimitive, IntoPrimitive,
59)]
60#[num_enum(error_type(name = u32, constructor = From::from))]
61#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
62#[cfg_attr(
63 feature = "strum",
64 derive(
65 strum::AsRefStr,
66 strum::Display,
67 strum::EnumCount,
68 strum::EnumIter,
69 strum::IntoStaticStr,
70 strum::VariantArray,
71 strum::VariantNames
72 )
73)]
74#[repr(u32)]
75pub enum GameLanguage {
76 English,
77 Korean,
78 French,
79 German,
80 Spanish,
81 Chinese,
82}